import { ApiProperty, IntersectionType, OmitType, PartialType } from "@nestjs/swagger";
import { $Enums } from "@prisma/client";
import { IsEnum, IsInt, IsOptional, IsPositive, IsString } from "class-validator";

import { QueryDto } from "@/core/dto/query.dto";

import { CreateFileDto } from "./create-file.dto";

export class QueryFileDto extends IntersectionType(QueryDto, PartialType(OmitType(CreateFileDto, ["hash"] as const))) {
    @IsOptional()
    @IsInt()
    @IsPositive()
    @ApiProperty({ description: "用户ID", example: 1, type: Number, required: false })
    userId: number;

    @IsOptional()
    @IsEnum($Enums.FileType)
    @ApiProperty({ description: "文件类型", enum: $Enums.FileType, required: false })
    fileType: $Enums.FileType;

    @IsOptional()
    @IsString()
    @ApiProperty({ description: "文件名", example: "头像.jpg", required: false })
    name: string;
}
